package com.duguo.dynamicmvc.model.statusmessage;

import com.duguo.dynamicmvc.factory.utils.BeanUtils;

public class PropertyStatusMessage implements StatusMessage {

	private int level=0;
	private String key;
	private Object[] args;
	
	public PropertyStatusMessage() {
	}

	public PropertyStatusMessage(String key) {
		this.key = key;
	}
	

	public PropertyStatusMessage(String key, Object[] args) {
		this.key = key;
		this.args = args;
	}

	public String getTitle() {
		return "message: "+key+".title";
	}

	public String getMessage() {
		//TODO: replace the code to get message from properties
		if(args!=null)
			return "message: "+key+".text args: "+BeanUtils.inspectObject(args);
		else
			return "message: "+key+".text";
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public Object[] getArgs() {
		return args;
	}

	public void setArgs(Object[] args) {
		this.args = args;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}
	
	public String toString(){
		return getLevel()+": "+getMessage();
	}
	
}
